import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:qr_flutter/qr_flutter.dart';
import '../utils/assets.dart';
import '../utils/provider.dart';

class CheckQr extends StatefulWidget {
  var memberEaseGroup;

   CheckQr(this.memberEaseGroup, {Key? key}) : super(key: key);

  @override
  State<CheckQr> createState() => _CheckQrState();
}

class _CheckQrState extends State<CheckQr> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getCommonAppBar("", color: Colors.black),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Container(
            margin: const EdgeInsets.only(top: 47),
            child: ClipRRect(
              borderRadius: BorderRadius.circular(5),
              child: CachedNetworkImage(
                imageUrl: Provider.fixAvatar(
                    widget.memberEaseGroup['groupUrl'] ?? ""),
                width: 60,
                height: 60,
                fit: BoxFit.fill,
              ),
            ),
          ),

          Center(
            child: Container(
              margin: const EdgeInsets.only(top: 10),
              child:  Text("群聊："+widget.memberEaseGroup['groupName'].toString()??"",
                style: const TextStyle(
                    color: Colors.black,
                    fontSize: 22,
                    fontWeight: FontWeight.bold),
              ),
            ),
          ),
          Container(
            margin: const EdgeInsets.only(top: 5),
            child:  Text("群号："+widget.memberEaseGroup['groupId'].toString()??"",
              style: const TextStyle(
                  color: Colors.grey,
                  fontSize: 14,
                  fontWeight: FontWeight.bold),
            ),
          ),
         Container(
           margin: const EdgeInsets.only(top: 20),
           child: QrImageView(
             data: widget.memberEaseGroup['groupId'].toString(),
             version: QrVersions.auto,
             size: 200,
           ),
         ),

          Container(
            margin: const EdgeInsets.only(top: 20),
            child: const Text(
              '该二维码7天内（5月3日前）有效\r\n过期将无法加入',
              textAlign: TextAlign.center,
              style: TextStyle(

                  color: Colors.black,
                  fontSize: 16,
                  fontWeight: FontWeight.normal),
            ),
          ),


        ],
      ),
    );
  }
}
